package com.haozhen.streaming

/**
  * @author haozhen
  * @email haozh@ync1.com
  * @date 2021/1/16  20:34
  */
object SocketServerLineNC {

  def main(args: Array[String]): Unit = {
    import java.net.{ServerSocket, Socket}
    val words = "hello world hello jadoop jell spark".split("\\s+")

    val socket = new ServerSocket(9999)

    val client: Socket = socket.accept()
    while (true){
      import java.io.PrintWriter
      val writer = new PrintWriter(client.getOutputStream)

      writer.println(words(scala.util.Random.nextInt(words.length))+" "+words(scala.util.Random.nextInt(words.length)))
      writer.flush()
      Thread.sleep(1000)
    }
  }
}
